#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>


//int x = 5, y = 7;
//void swap()
//{
//	int z;
//	z = x;
//	x = y;
//	y = z;
//} 
//int main()
//{
//	int x = 3, y = 8;
//	swap();
//	printf("%d,%d\n",x, y);
//	return 0;
//}


int is_leap_year(int y)
{
	if (y%4==0 && y%100 !=0 || y%400 ==0)
	{
		return 1;
	}
	else
		return 0;
}

int main()
{
	int arr[12] = {31,28,31,30,31,30,31,31,30,31,30,31 };
	int year = 0;
	int month = 0;
	int day = 0;
	int sum = 0;
	while ((scanf_s("%d%d%d", &year, &month, &day)) != EOF)
	{
		sum = day;
		if (is_leap_year(year) && month > 2)
		{
			sum += 1;
		}
		for (int i = 1; i < month; i++)
		{
			sum += arr[i];
		}
		printf("%d", sum);
	}
	
	return 0;
}